//
//  SFCPreferenceViewController.m
//  SVNForCocoa
//
//  Created by Jeremy Pereira on 26/12/2013.
//  Copyright (c) 2013 Jeremy Pereira. All rights reserved.
//

#import "SFCPreferenceViewController.h"

NSString* const SFC_PREFS_DEBUG_CONSTRAINTS
	= @"NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints";

@interface SFCPreferenceViewController ()

@end

@implementation SFCPreferenceViewController

@synthesize visualiseConstraintsButton = _visualiseConstraintsButton;

-(void) windowDidLoad
{
	NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
    [defaults synchronize];
    BOOL visualizeConstraints = [defaults boolForKey: SFC_PREFS_DEBUG_CONSTRAINTS];
    [[self visualiseConstraintsButton]
     setState: visualizeConstraints ? NSOnState : NSOffState];
}

-(IBAction) setVisualiseConstraints: (id) sender
{
	NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
    BOOL visualiseContraints = [[self visualiseConstraintsButton] state] == NSOnState;
    [defaults setBool: visualiseContraints forKey: SFC_PREFS_DEBUG_CONSTRAINTS];
    [defaults synchronize];
}

@end
